package ch5;

import java.util.Scanner;

public class CalcAvg {

	public static void main(String[] args) {
		// 计算5门课的成绩平均分
		Scanner in = new Scanner(System.in);
		double total = 0;
		double avg = 0;
		double s = 0;
		for (int i = 1; i <= 5; i++) {
			System.out.printf("请输入第%d门课的成绩：\n", i);
			s = in.nextDouble();
			if (s < 0 || s > 150) {
				System.out.println("输入错误，分值在【0-150】之间！");
				break;
			}
			total += s;
		}
		// 有问题，没有解决提前结束的时候，不计算平均分
		avg = total / 5;
		System.out.println("平均分是:" + avg);
	}
}
